
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
    #region ShipCountry Model -(by fangyifeng at 2010-12-28 23:07:07)

    /// <summary>
    /// ShipCountry object'ShipCountry'.
    /// </summary>
    public class ShipCountry : System.IComparable
    {
        #region Member Variables

        protected Guid _id;
        protected short _areaNumber;
        protected Country _country;
        protected ShipMethod _shipMethod;
        protected ShipCompany _shipCompany;

        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public ShipCountry() { }

        public ShipCountry(short areaNumber, Country country, ShipMethod shipMethod, ShipCompany shipCompany)
        {
            this._areaNumber = areaNumber;
            this._country = country;
            this._shipMethod = shipMethod;
            this._shipCompany = shipCompany;
        }

        #endregion

        #region Public Properties

        public virtual Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public virtual short AreaNumber
        {
            get { return _areaNumber; }
            set { _areaNumber = value; }
        }

        public virtual Country Country
        {
            get { return _country; }
            set { _country = value; }
        }


        public virtual ShipMethod ShipMethod
        {
            get { return _shipMethod; }
            set { _shipMethod = value; }
        }


        public virtual ShipCompany ShipCompany
        {
            get { return _shipCompany; }
            set { _shipCompany = value; }
        }


        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
            if (!(obj is ShipCountry))
                throw new InvalidCastException("This object is not of type ShipCountry");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((ShipCountry)obj).Id);
                    break;
                case "AreaNumber":
                    relativeValue = (this.AreaNumber != null) ? this.AreaNumber.CompareTo(((ShipCountry)obj).AreaNumber) : -1;
                    break;
                default:
                    goto case "Id";
            }
            if (ShipCountry.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
